Parameters
User-defined subroutines, like the built-in functions of the VectorScript API, make use of parameters and parameter lists to move data values in and out of subroutines.
Formal and Actual Parameters
Formal parameters in VectorScript refer to the parameters which are defined in the parameter lists of built-in or user-defined functions. Formal parameters provide the data interface “template” for the function, indicating the order and typing of the values that will be passed in and out of the function call. Actual parameters refer to the expressions or values that are passed by a function in the body of the script. For example, in the declaration statement of the subroutine SumOfSquares:
PROCEDURE SumOfSquares(limit:INTEGER;VAR result:INTEGER);
The identifier’s limit and result are both formal parameters of the subroutine procedure. When SumOfSquares is used in the script:
SumOfSquares(n,sum);
the subroutine procedure has two actual parameters, n and sum. These actual parameters contain the data used and returned by the function call. Checking the VAR block of the script, notice that the data types of the two identifiers match the types found in the formal parameter list.
Value and Variable Parameters
Value parameters in VectorScript are parameters which are used to pass data values into a subroutine. Within the subroutine, they act just like local variables except that they obtain their initial value from a corresponding actual parameter in the parameter list. In the SumOfSquares example:
PROCEDURE SumOfSquares(limit:INTEGER;VAR result:INTEGER);
the identifier limit is a value parameter, or more fully, a formal value parameter. In the function call of the main script:
SumOfSquares(n,sum);
the value contained in the variable n would be assigned to the value parameter limit for use within the subroutine.
Variable parameters in VectorScript are the opposite of value parameters—they are used to pass data values out of a subroutine. They are denoted by the VAR keyword which precedes them in the parameter list, and like value parameters, act as local variables within the subroutine. In the SumOfSquares example:
PROCEDURE SumOfSquares(limit:INTEGER;VAR result:INTEGER);
the identifier result is a formal variable parameter, which can be used within the subroutine script code to pass values back to the calling code. In the function call of the main script:
SumOfSquares(n,sum);
the value contained in the variable parameter result would be assigned to the variable sum when the subroutine finished execution.

User Defined Functions : Parameters

Nemetschek NA
Phone: 410.290.5114
Fax: 410.290.8050